package org.jeecg.common.fs;

import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 文件上传和下载扩展信息
 */
public class FileExtInfo {
    /**
     * 集合名称
     */
    private String tableName = "fs.upload";

    /**
     * 其他信息
     */
    private JSONObject extMap = new JSONObject();

    public FileExtInfo() {
        this.tableName = tableName;
    }

    public FileExtInfo(String tableName) {
        this.tableName = tableName;
    }

    /**
     * 添加扩展信息
     * @param key
     * @param value
     * @return
     */
    public FileExtInfo add(String key, Object value){
        this.extMap.put(key, value);
        return this;
    }

    /**
     * 获取所有的key
     * @return
     */
    public List<String> getKeys(){
        return new ArrayList<>(this.extMap.keySet());
    }

    public String getString(String key){
        return (String) this.extMap.get(key);
    }

    public Object getObject(String key){
        return this.extMap.get(key);
    }

    public String getTableName() {
        return tableName;
    }

    public JSONObject getExtMap() {
        return extMap;
    }

    public String toExtJSONString(){
        return extMap.toJSONString();
    }
}
